import { connect } from "react-redux";

function Hello({ msg, fn1, fn2, changeMsg }) {
  return (
    <div>
      <h2>Hello</h2>
      <p>msg: {msg}</p>
      <button onClick={() => changeMsg("张三")}>changeMsg - 张三</button>
      <button onClick={() => changeMsg("里斯")}>changeMsg - 里斯</button>
    </div>
  );
}

export default connect(
  (state) => ({
    msg: state.app.msg,
  }),
  {
    fn1: () => ({ type: "CHANGEMSG", payload: "张三" }),
    fn2: () => ({ type: "CHANGEMSG", payload: "里斯" }),

    changeMsg: (payload) => ({ type: "CHANGEMSG", payload }),
  }
)(Hello);
